package com.suke.controller;

import com.suke.domain.Emp;
import com.suke.domain.Result;
import com.suke.util.EmpFeginClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author java43.熊佳
 * @date 2020/8/20 9:46
 * @Description
 */
@RestController
@RequestMapping("/ec")
public class EmpController {
    /*@Autowired
	private RestTemplate restTemplate;

	@Value("${helloService.servicePath}")
	private String findbyidpath;

	@RequestMapping(value="findempbyid/{empno}",method=RequestMethod.GET)
	public Result findemp(@PathVariable("empno") Integer empno) {
		Result res = restTemplate.getForObject(findbyidpath+empno, Result.class);
		return res;
	}*/
    @Autowired
    private EmpFeginClient empClient;

    @RequestMapping(value="findempbyid/{empno}",method= RequestMethod.GET)
    public Result findemp(@PathVariable("empno") Integer empno) {
        Result result = empClient.findEmpByEmpno(empno);
        return result;
    }

    @RequestMapping(value="addemp",method=RequestMethod.POST)
    public void addemp(Emp emp) {
        empClient.addEmp(emp);
    }
}
